package com.yzy.controller;

import com.yzy.dao.DoctorDao;
import com.yzy.dao.PatientDao;
import com.yzy.entity.Doctors;
import com.yzy.entity.Patients;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class PatientAddServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String patientphone = request.getParameter("patientphone");
        String patientname = request.getParameter("patientname");
        String patientage = request.getParameter("patientage");

        String patientpass = request.getParameter("patientpass");
        String patientsex = request.getParameter("patientsex");
        String patienthistory = request.getParameter("patienthistory");
        PatientDao dao=new PatientDao();
        Patients patient = null;
        int result=0;
        PrintWriter out = null;
        //2
        patient = new Patients(patientphone,patientname,patientage,patientpass,patientsex,patienthistory);
        result=dao.add(patient);
        //3
        response.setContentType("text/html;charset=utf-8");
        out=response.getWriter();
        if(result == 1){
            out.print("<font style='color:red;font-size:40'>患者信息注册成功</font>");
        }else{
            out.print("<font style='color:red;font-size:40'>患者信息注册失败</font>");
        }
    }
}
